<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        用函数实现内置map方法
    </div>
    <script>
        function myMap ( arr , fn ) {
            var newArr = [] ;
            for ( var i = 0 ; i < arr.length ; i ++ ){
                var res = fn( arr[i] , i , arr ) ;
                newArr.push(res);
            }
            return newArr ;
        }
        var arr = ["张三","李四","王五","甘六"] ; 
        var newArr = myMap( arr , function ( item , key , arr ){
            return item ; 
        } ) ; 
        console.log(newArr);
    </script>
</body>
</html>